const Mock = require('mockjs')

const data = Mock.mock({
  'items|30': [{
    id: '@id',
    title: '@sentence(10, 20)',
    'status|1': ['published', 'draft', 'deleted'],
    author: 'name',
    display_time: '@datetime',
    pageviews: '@integer(300, 5000)'
  }]
})

const county = Mock.mock({
  'items|3': [{
    id: '@id',
    name: '@county 隧道',
    updateTime: '@datetime'
  }]
})

const city = Mock.mock({
  'items|3': [{
    id: '@id',
    name: '@city 标段',
    children: county.items,
    updateTime: '@datetime'
  }]
})

const table = Mock.mock({
  'sidebar|3': [{
    id: '@id',
    name: '@province 铁路线',
    children: city.items,
    total: '@integer(30, 500) / @integer(30, 500)',
    pageviews: '@integer(30, 500)',
    updateTime: '@datetime'
  }],
  'items|10': [{
    id: '@id',
    name: '@city 标段',
    total: '@integer(30, 500) / @integer(30, 500)',
    pageviews: '@integer(30, 500)',
    updateTime: '@datetime'
  }]
})

module.exports = [
  {
    url: '/vue-admin-template/table/list',
    type: 'get',
    response: config => {
      const items = data.items
      return {
        code: 200,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  },
  {
    url: '/dashboard/table',
    type: 'get',
    response: config => {
      const items = table.items
      const sidebar = table.sidebar
      return {
        code: 200,
        data: {
          total: items.length * 10,
          items: items,
          sidebar: sidebar
        }
      }
    }
  }
]
